home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.3 / Printer / src / EpsonQ / dospecial.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  4.2 KB  |  200 lines

  1. /*
  2.     DoSpecial for EpsonQ driver.
  3.     David Berezowski - March/88.
  4.  
  5.   Copyright (c) 1988 Commodore-Amiga, Inc.
  6.  
  7.   Executables based on this information may be used in software
  8.   for Commodore Amiga computers.  All other rights reserved.
  9.  
  10.   This information is provided "as is"; no warranties are made.
  11.   All use is at your own risk, and no liability or responsibility is assumed.
  12. */
  13.  
  14.  
  15. #include "exec/types.h"
  16. #include "../printer/printer.h"
  17. #include "../printer/prtbase.h"
  18.  
  19. DoSpecial(command, outputBuffer, vline, currentVMI, crlfFlag, Parms)
  20. char outputBuffer[];
  21. UWORD *command;
  22. BYTE *vline;
  23. BYTE *currentVMI;
  24. BYTE *crlfFlag;
  25. UBYTE Parms[];
  26. {
  27.     extern struct PrinterData *PD;
  28.  
  29.     int x = 0, y = 0;
  30.     /*
  31.         00-01    \0335        italics off
  32.         02-04    \033-\000    underline off
  33.         05-06    \033F        boldface off
  34.         07-08    \033P        elite off
  35.         09-09    \022        condensed fine off
  36.         10-12    \033W\000    enlarge off
  37.         13-14    \033H        double strike off
  38.         15-17    \033x\000    NLQ off
  39.         18-19    \033T        normalize the line
  40.         20-22    \033R\000    US char set
  41.         23-25    \033p0        proportional off
  42.         26-27    \0332        6 lpi
  43.         28-28    \015        carriage-return
  44.     */
  45.     static char initThisPrinter[29] =
  46. "\0335\033-\376\033F\033P\022\033W\376\033H\033x\376\033T\033R\376\033p0\0332\015";
  47.     static char initMarg[] = "\375\033lL\033QR\375";
  48.     static BYTE ISOcolorTable[] = {0, 5, 6, 4, 3, 1, 2, 0};
  49.  
  50.     if (*command == aRIN) { /* initialize */
  51.         while(x < 29) {
  52.             if ((outputBuffer[x] = initThisPrinter[x]) == -2) {
  53.                 outputBuffer[x] = 0;
  54.             }
  55.             x++;
  56.         }
  57.  
  58.         if (PD->pd_Preferences.PrintQuality == LETTER) {
  59.             outputBuffer[17] = 1;
  60.         }
  61.  
  62.         *currentVMI = 30; /* assume 1/6 line spacing */
  63.         if (PD->pd_Preferences.PrintSpacing == EIGHT_LPI) {
  64.             outputBuffer[27] = '0';
  65.             *currentVMI = 22;
  66.         }
  67.  
  68.         if (PD->pd_Preferences.PrintPitch == ELITE) {
  69.             outputBuffer[8] = 'M';
  70.         }
  71.         else if (PD->pd_Preferences.PrintPitch == FINE) {
  72.             outputBuffer[9] = 15;
  73.         }
  74.  
  75.         Parms[0] = PD->pd_Preferences.PrintLeftMargin;
  76.         Parms[1] = PD->pd_Preferences.PrintRightMargin;
  77.         *command=aSLRM;
  78.     }
  79.  
  80.     if (*command == aCAM) { /* cancel margins */
  81.         y = PD->pd_Preferences.PaperSize == W_TRACTOR ? 136 : 80;
  82.         if (PD->pd_Preferences.PrintPitch == PICA) {
  83.             Parms[1] = (10 * y) / 10;
  84.         }
  85.         else if (PD->pd_Preferences.PrintPitch == ELITE) {
  86.             Parms[1] = (12 * y) / 10;
  87.         }
  88.         else { /* fine */
  89.             Parms[1] = (17 * y) / 10;
  90.         }
  91.         Parms[0] = 1;
  92.         y = 0;
  93.         *command = aSLRM;
  94.     }
  95.  
  96.     if (*command == aSLRM) { /* set left&right margins */
  97.         PD->pd_PWaitEnabled = 253; /* wait after this character */
  98.         if (Parms[0] == 0) {
  99.             initMarg[3] = 0;
  100.         }
  101.         else {
  102.             initMarg[3] = Parms[0] - 1;
  103.         }
  104.         initMarg[6] = Parms[1];
  105.         while (y < 8) {
  106.             outputBuffer[x++] = initMarg[y++];
  107.         }
  108.         return(x);
  109.     }
  110.  
  111.     if (*command == aPLU) { /* partial line up */
  112.         if (*vline == 0) {
  113.             *vline = 1;
  114.             *command = aSUS2;
  115.             return(0);
  116.         }
  117.         if (*vline < 0) {
  118.             *vline = 0;
  119.             *command = aSUS3;
  120.             return(0);
  121.         }
  122.         return(-1);
  123.     }
  124.  
  125.     if (*command == aPLD) { /* partial line down */
  126.         if (*vline == 0) {
  127.             *vline = -1;
  128.             *command = aSUS4;
  129.             return(0);
  130.         }
  131.         if (*vline > 0) {
  132.             *vline = 0;
  133.             *command = aSUS1;
  134.             return(0);
  135.         }
  136.         return(-1);
  137.     }
  138.  
  139.     if (*command == aSUS0) { /* normalize the line */
  140.         *vline = 0;
  141.     }
  142.  
  143.     if (*command == aSUS1) { /* superscript off */
  144.         *vline = 0;
  145.     }
  146.  
  147.     if (*command == aSUS2) { /* superscript on */
  148.         *vline = 1;
  149.     }
  150.  
  151.     if (*command == aSUS3) { /* subscript off */
  152.         *vline = 0;
  153.     }
  154.  
  155.     if (*command == aSUS4) { /* subscript on */
  156.         *vline = -1;
  157.     }
  158.  
  159.     if (*command == aVERP0) { /* 8 LPI */
  160.         *currentVMI = 22;
  161.     }
  162.  
  163.     if (*command == aVERP1) { /* 6 LPI */
  164.         *currentVMI = 30;
  165.     }
  166.  
  167.     if (*command == aSFC) { /* set foreground/background color */
  168.         if (Parms[0] == 39) {
  169.             Parms[0] = 30; /* set default (black) */
  170.         }
  171.         if (Parms[0] > 37) {
  172.             return(0); /* ni or background color change */
  173.         }
  174.         outputBuffer[x++] = 27;
  175.         outputBuffer[x++] = 'r';
  176.         outputBuffer[x++] = ISOcolorTable[Parms[0] - 30];
  177.         return(x);
  178.     }
  179.  
  180.     if (*command == aSLPP) { /* set form length */
  181.         outputBuffer[x++] = 27;
  182.         outputBuffer[x++] = 'C';
  183.         outputBuffer[x++] = Parms[0];
  184.         return(x);
  185.     }
  186.  
  187.     if (*command == aPERF) { /* perf skip n */
  188.         outputBuffer[x++] = 27;
  189.         outputBuffer[x++] = 'N';
  190.         outputBuffer[x++] = Parms[0];
  191.         return(x);
  192.     }
  193.  
  194.     if (*command == aRIS) { /* reset */
  195.         PD->pd_PWaitEnabled = 253;
  196.     }
  197.  
  198.     return(0);
  199. }
  200.